package cn.kgc.tangcco.context;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;

/**
 * @author 李昊哲
 * @Description
 * @create 2020/10/15 下午5:15
 */
@WebServlet(urlPatterns = "/context02")
public class ServletContext02 extends HttpServlet {
    private static final long serialVersionUID = 1915900251575531644L;

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletContext context = this.getServletContext();
        Enumeration<String> names = context.getInitParameterNames();
        while (names.hasMoreElements()) {
            String name = names.nextElement();
            System.out.println("name = " + name + "\tvalue = " + context.getInitParameter(name));
        }
    }
}
